package com.easy.service.impl;

import com.easy.zhu.LogMethod;
import com.easy.bean.FosterBean;
import com.easy.mapper.FosterBeanDao;
import com.easy.service.FosterBeanService;
import com.easy.util.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class FosterServiceImpl implements FosterBeanService {
    @Autowired
    FosterBeanDao fosterBeanDao;
    @Override
    @LogMethod(serviceName = "用户添加处理")
    public FosterBean add(FosterBean fosterBean) {
        fosterBeanDao.add(fosterBean);
        FosterBean result = fosterBeanDao.one(fosterBean.getId());
        return result;
    }

    @Override
    @LogMethod(serviceName = "用户删除处理")
    public int del(Integer id) {
        return fosterBeanDao.del(id);
    }

    @Override
    @LogMethod(serviceName = "用户修改处理")
    public FosterBean edit(FosterBean fosterBean) {
        fosterBeanDao.edit(fosterBean);
        FosterBean result = fosterBeanDao.one(fosterBean.getId());
        return result;
    }

    @Override
    @LogMethod(serviceName = "用户查询处理")
    public List<FosterBean> all(FosterBean fosterBean) {
        return fosterBeanDao.all(fosterBean);
    }

    @Override
    @LogMethod(serviceName = "用户查询处理")
    public FosterBean one(Integer id) {
        return fosterBeanDao.one(id);
    }

    @Override
    @LogMethod(serviceName = "用户分页处理")
    public void page(Page page, FosterBean fosterBean) {
        int count=fosterBeanDao.pageCount(fosterBean);//查询数据总条数
        Object data=fosterBeanDao.page(page,fosterBean);//查询当前页的数据
        page.setCount(count);//设置总条数
        page.setData(data);//设置当前页的数据
    }
}
